<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:crm="http://www.thymeleaf.org/crm"
	xmlns:dt="http://github.com/dandelion/datatables">

<head th:replace="fragment/common :: header"></head>
<body>

	<div th:replace="fragment/common :: topnav"></div>

	<div id="wrap">

		<div class="container-fluid">

			<div class="row">
				<div class="span8">
					<h4 th:if="${newLead}">New Lead</h4>
					<h4 th:if="${view}">View Lead Details</h4>
					<h4 th:if="${edit}">Edit Lead</h4>
				</div>
				<div class="span4 pull-right">
					<div class="btn-group pull-right">
						<a class="btn btn-primary" href="list"> <i
							class="fa fa-plus-square"></i> View Leads
						</a>
						<button class="btn btn-warning">
							<i class="fa fa-upload"></i> Import Leads
						</button>

					</div>
				</div>
			</div>


			<form th:action="${id == null} ? @{/lead/save} : @{/lead/update}"
				class="form-horizontal small labels" method="POST"
				th:object="${lead}">
				<input type="hidden" th:field="*{id}" />
				
				<div class="row-fluid" th:if="${edit}">
					<div class="alert alert-success" th:if="${message != null}">
						<button type="button" class="close" data-dismiss="alert">&times;</button>
						<b>Success!</b> Lead updated successfully.
					</div>
				</div>

				<div class="row-fluid" th:if="${newLead or view}">
					<div class="alert alert-success" th:if="${message != null}">
						<button type="button" class="close" data-dismiss="alert">&times;</button>
						<b>Success!</b> Lead saved successfully.
					</div>
				</div>
				
				

				<fieldset>
					<legend>
						Lead Information

						<div class="pull-right">
							<button type="submit" class="btn btn-primary" th:if="${!view}">Save</button>
							<button type="button" class="btn" th:if="${!view}">Cancel</button>
							
							
							
							<a  class="btn btn-primary" th:href="@{/lead/edit(id=*{id})}" th:if="${view}">Edit</a>
							<a  class="btn btn-danger" th:href="@{/lead/delete(id=*{id})}" th:if="${view}">Delete</a>
							<a  class="btn btn-info" th:href="@{/lead/copy(id=*{id})}" th:if="${view}">Copy</a>
							
							<a class="btn" href="list" th:if="${view}">Back</a>
							
						</div>

					</legend>


					<div class="row-fluid ">

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="salutation">Salutation</label>
								<div class="controls">


									<select th:field="*{salutation}" class="span12"  th:disabled="${view}">
										<option
											th:each="s : ${salutationList}"
											th:value="${s.id}" th:text="#{${s.key}}" th:selected="${lead.salutation eq s}"></option>
									</select>

								</div>
							</div>

						</div>

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="firstName">First Name</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{firstName}"  th:disabled="${view}"/>

								</div>
							</div>
						</div>

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="lastName">Last Name</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{lastName}"
										required="required"  th:disabled="${view}"/>

								</div>
							</div>
						</div>

					</div>

					<div class="row-fluid ">

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="company">Company</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{company}"  th:disabled="${view}"/>


								</div>
							</div>
						</div>

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="title">Designation</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{title}"  th:disabled="${view}"/>
								</div>
							</div>
						</div>



						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="inputEmail">Industry</label>
								<div class="controls">


									<select th:field="*{industry}" class="span12" th:disabled="${view}">
										<option
											th:each="s : ${industries}"
											th:value="${s.id}" th:text="#{${s.key}}" th:selected="${lead.industry eq s}"></option>
									</select>

								</div>
							</div>

						</div>

					</div>

					<div class="row-fluid ">

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="annualRevenue">Annual
									Revenue</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{annualRevenue}"  th:disabled="${view}"/>
								</div>
							</div>
						</div>

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="title">Website</label>
								<div class="controls">

									<div class="input-prepend span12">
										<span class="add-on span2">http://</span> <input type="text"
											class="span10" th:field="*{website}"  th:disabled="${view}"/>
									</div>

								</div>
							</div>
						</div>



						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="title"># of Employees</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{noOfEmployees}"  th:disabled="${view}"/>

								</div>
							</div>
						</div>


					</div>


					<div class="row-fluid ">

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="phone">Phone</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{phone}"  th:disabled="${view}"/>
								</div>
							</div>
						</div>

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="mobile">Mobile</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{mobile}"
										required="required"  th:disabled="${view}"/>

								</div>
							</div>
						</div>



						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="fax">Fax</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{fax}"  th:disabled="${view}"/>

								</div>
							</div>
						</div>


					</div>


					<div class="row-fluid ">

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="source">Lead Source</label>
								<div class="controls">

									
									
									<select th:field="*{source}" class="span12" th:disabled="${view}">
										<option
											th:each="s : ${sourceList}"
											th:value="${s.id}" th:text="#{${s.key}}" th:selected="${lead.source eq s}"
											></option>
									</select>

								</div>
							</div>
						</div>

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="rating">Rating</label>
								<div class="controls">


									<select th:field="*{rating}" class="span12" th:disabled="${view}">
										<option
											th:each="s : ${ratingList}"
											th:value="${s.id}" th:text="#{${s.key}}" th:selected="${lead.rating eq s}"></option>
									</select>

								</div>
							</div>
						</div>



						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="status">Lead Status</label>
								<div class="controls">


									<select th:field="*{status}" class="span12" th:disabled="${view}">
										<option
											th:each="s : ${statusList}"
											th:value="${s.id}" th:text="#{${s.key}}" th:selected="${lead.status eq s}"></option>
									</select>

								</div>
							</div>

						</div>

					</div>


					<div class="row-fluid ">

						<div class="span4">

							<div class="control-group"
								th:class="${#fields.hasErrors('email') ? 'control-group error' : 'control-group'}">
								<label class="control-label" for="email">Email</label>
								<div class="controls">
									<input type="email" class="span12" th:field="*{email}"  th:disabled="${view}"/>
								</div>
							</div>
						</div>

						<div class="span4">

							<div class="control-group"
								th:class="${#fields.hasErrors('secondaryEmail') ? 'control-group error' : 'control-group'}">
								<label class="control-label" for="secondaryEmail">Secondary
									Email</label>
								<div class="controls">
									<input type="email" class="span12" th:field="*{secondaryEmail}"  th:disabled="${view}"/>

								</div>
							</div>
						</div>
						
						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="fax">Assigned To</label>
								<div class="controls">
									<input type="radio" value="User" checked="checked" name="assign" th:disabled="${view}">User</input>
									<input type="radio" value="Team" name="assign" th:disabled="${view}">Team</input>
									
									<select th:field="*{assignedUser}" th:disabled="${view}">
  										<option th:each="u : ${users}" th:value="${u}" 
          									th:text="${u}"></option>
									</select>
									
									<select th:field="*{assignedTeam}" th:disabled="${view}">
  										<option th:each="t : ${teams}" th:value="${t}" 
          									th:text="${t}"></option>
									</select>
									

								</div>
							</div>
						</div>

					</div>
					
					<div class="row-fluid ">

						

						<div class="span12">

							<div class="control-group">
								<label class="control-label" for="description">Description</label>
								<div class="controls">
									
									<textarea rows="3" cols="30" th:field="*{description}" class="span12" th:disabled="${view}"
                                                                        > </textarea>
								</div>
							</div>
						</div>


					</div>
					
					

				</fieldset>
				
				
				<fieldset>
					<legend>Address Information</legend>
					
					<div class="row-fluid ">

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="city">City</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{address.city}"  th:disabled="${view}"/>
								</div>
							</div>
						</div>

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="state">State</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{address.state}"  th:disabled="${view}"/>
								</div>
							</div>
						</div>



						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="title">Country</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{noOfEmployees}"  th:disabled="${view}"/>

								</div>
							</div>
						</div>


					</div>
					
					
					<div class="row-fluid ">

						<div class="span4">

							<div class="control-group">
								<label class="control-label" for="zip">Zip</label>
								<div class="controls">
									<input type="text" class="span12" th:field="*{address.zip}"  th:disabled="${view}"/>
								</div>
							</div>
						</div>

						<div class="span8">

							<div class="control-group">
								<label class="control-label" for="street">Street</label>
								<div class="controls">
									
									<textarea rows="3" cols="30" th:field="*{address.street}" class="span12"
                                                                         th:disabled="${view}"> </textarea>
								</div>
							</div>
						</div>


					</div>
					
				
				</fieldset>

				<div class="row-fluid">

					<div class="pull-right">
						<button type="submit" class="btn btn-primary" th:if="${!view}">Save</button>
							<button type="button" class="btn" th:if="${!view}">Cancel</button>
							
							
							
							<a  class="btn btn-primary" th:href="@{/lead/edit(id=*{id})}" th:if="${view}">Edit</a>
							<a  class="btn btn-danger" th:href="@{/lead/delete(id=*{id})}" th:if="${view}">Delete</a>
							<a  class="btn btn-info" th:href="@{/lead/copy(id=*{id})}" th:if="${view}">Copy</a>
							
							<a class="btn" href="list" th:if="${view}">Back</a>
					</div>

				</div>


			</form>


		</div>


		<div id="push"></div>
	</div>
	
	<!-- 
	<footer th:replace="fragment/common :: footer"></footer>
	 -->
	
	<script type="text/javascript">
			$(document).ready(function() {
				

					$( 'input[required="true"]' )
			        .closest(".control-group")
			        .children("label")
			        .prepend('<i class="icon-asterisk"></i>');
					
					$( 'input[required="required"]' )
			        .closest(".control-group")
			        .children("label")
			        .prepend('<i class="icon-asterisk"></i>');
					
					$("#assignedTeam").hide();
					
					$("input[value='User']").click(function(){
					    if($(this).is(":checked")){
					    	
					    	alert('user clicked');
					    	
					       $("#assignedUser").show();
					       $("#assignedTeam").hide();
					    }
					       
					
					});

					    $("input[value='Team']").click(function(){
					    	alert('team clicked');
					        if($(this).is(":checked")){
					           $("#assignedTeam").show();
					           $("#assignedUser").hide();
					        }
					    });
					
					
					

				});
	</script>



</body>
</html>